
package com.android.matmanual;

import com.android.internal.telephony.PhoneFactory;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.widget.TextView;
public class SimTest extends BaseActivity {
	TextView sim1Tv;
	TextView sim2Tv;
	String sim1;
	String sim2;
	WakeLock mWakeLock;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.simtest);
		setTitle(R.string.sim_title);
		
	    PowerManager pm =
		           (PowerManager) getSystemService(POWER_SERVICE); 
	    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, 
		          "XYTEST"); 
		mWakeLock.acquire(); 
		sim1Tv=(TextView)findViewById(R.id.sim1);
		sim2Tv=(TextView)findViewById(R.id.sim2);
		
		TelephonyManager tm1 = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);	
		TelephonyManager tm2 = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    
		sim1=tm1.getNetworkOperatorGemini(0);
		sim2=tm2.getNetworkOperatorGemini(1);
		
        if("".trim().equals(sim1)){
        	sim1Tv.setText(R.string.notfoundsim);
        }else{
        	if(sim1.equals("46002")||sim1.equals("46000")||sim1.equals("46007")){
        		sim1Tv.setText(R.string.yidong);
        	}
        	if(sim1.equals("46001")){
        		sim1Tv.setText(R.string.liantong);
        	}
        	if(sim1.equals("46003")){
        		sim1Tv.setText(R.string.dianxin);
        	}
        }
        if("".trim().equals(sim2)){
        	sim2Tv.setText(R.string.notfoundsim);
        }else{
        	if(sim2.equals("46002")||sim2.equals("46000")||sim2.equals("46007")){
        		sim2Tv.setText(R.string.yidong);
        	}
        	if(sim2.equals("46001")){
        		sim2Tv.setText(R.string.liantong);
        	}
        	if(sim2.equals("46003")){
        		sim2Tv.setText(R.string.dianxin);
        	}
        }
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		int result = TestControl.GetKeyEvent(keyCode);
		if (result != TestControl.DO_NOTHING) {
			setResult(result);
			finish();
	    }
	    return true;
	}
	    @Override
	    protected void onDestroy() {
	    	// TODO Auto-generated method stub
			if(mWakeLock!=null)
			{
				mWakeLock.release(); 
				mWakeLock = null;
			}
	    	super.onDestroy();
	    }	 
	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
       finish();
		super.onStop();
	}

	@Override
	public void onAttachedToWindow() 
	{
		// TODO Auto-generated method stub
		super.onAttachedToWindow();
		this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
	}

}
		 